let app = getApp();
Page({
  data: {
    openid:null,
    options:null,
    userinfo:null,
  },
  onLoad (options) {
    let that = this;
     wx.getStorage({
      key: 'userinfo',
      success(res) {
        that.setData({
          userinfo: JSON.parse(res.data)
        })
      },
    })
    wx.getStorage({
      key: 'openid',
      success(res) {
        that.setData({
          openid: res.data,
          options: options
        })
      }
    });    
  },
  submitForm(e){
    let comment = e.detail.value.compary;
    app.get('PingLun',{
      action: 'insert',
      openid:this.data.openid,
      shangpinid: this.data.options.id,
      shangpinmingcheng: this.data.options.name,
      pinglunneirong: comment,
      nicheng: this.data.userinfo.nickName,
      chengshi: this.data.userinfo.city,
      weixintouxiang: this.data.userinfo.avatarUrl,
    }).then((res)=>{    
      wx.navigateBack({
        delta:1
      });
      app.toast(res.msg);
    })    
  }
})